<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>修德抄经堂</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" type="text/css" href="../bower_components/mui/dist/css/mui.css">
	<link rel="stylesheet" type="text/css" href="../css/base.css">
	<link rel="stylesheet" type="text/css" href="../css/over.css">
	<link rel="stylesheet" type="text/css" href="../css/zhuchao.css">
	<link rel="stylesheet" type="text/css" href="../css/full.css">
	<script src="../bower_components/mui/dist/js/mui.min.js"></script>
	<script src="../bower_components/jquery/dist/jquery.js"></script>
    <script src="../js/common.js"></script>
</head>
<body>
	<div class="page">
		<div class="bg"></div>
	   <div class="content">
	   		 <div id="main">
			<!--<div class="img_bg"></div>
	   			<div class="img_border">
					<div class="shuming">
		   				<p class="p1 same">《心经》王羲之行书线装本</p>
		   				<p class="p2 fang">李某某 2017.05.05发愿</p>
		   			</div>
	   				<img src="../img/bore/book.png">
	   			</div>
				<div class="fayuan">
		   			<p class="p1 same">发愿文</p>
		   			<p class="p2 fang">愿过去佛，现在佛，未来佛，常说般若菠萝蜜；愿一切受持者，比丘尼、信男、信女，所求如意，常兴般若菠萝蜜</p>
		   		</div>
	   		
                	三个图标
                
                <ul class="btn">
                	<a href="read.html"><li>
                		<img src="../img/benxin/read.png">
                		<p>阅读</p>
                	</li></a>
                	<a href="chaoxieer.html"><li>
                		<img src="../img/benxin/write2.png">
                		<p>助抄</p>
                	</li></a>
                	<a href="caoxuexuanze.html"><li>
                		<img src="../img/benxin/write.png">
                		<p>自抄</p>
                	</li></a>
                </ul> 
                -->
	   		</div>
	   </div>
	</div>
</body>
    <script src="../js/common.js"></script>
<script>
	$('.img_bg').height($('.img_border img').height()+21);
	$('.shuming').width($('.img_border img').width()+20)
</script>
<script>
    var userTranscriptionID = getUrlParam('id');
    var html = '';

    $.ajax({
            url: '/fe/assistance/user_transcription/'+userTranscriptionID+'/info',
            data: {
            },
            async: false,
            success: function (data) {
                    var sutra_id = data.data.sutra.cover_url;
                if (data.data.transcription.vow_time)
                    html += '<div class="img_bg"></div>'+
                    '<div class="img_border">'+
                    '<div class="shuming">'+
                    '<p class="p1 same">'+data.data.sutra.name+'</p>'+
                    '<p class="p2 fang">'+parseISODate(data.data.transcription.vow_time).format("yyyy.MM.dd")+'</p>'+'</div>'+
                    '<img src="'+sutra_id+'">'+'</div>'
                    +'<div class="fayuan">'+
                    '<p class="p1 same">发愿文</p>'+
                    '<textarea class="p2 fang">'+data.data.transcription.vow_text+'</textarea>'+'</div>'+
                    '<ul class="btn">'+
                    '<a href="read.html?id='+data.data.sutra.id+'"><li>'+
                        '<img src="../img/benxin/read.png">'+
                        '<p>阅读</p>'+
                    '</li></a>'+
                    '<a href="#" id = "zhuchao"><li>'+
                        '<img src="../img/benxin/write2.png">'+
                        '<p>助抄</p>'+
                    '</li></a>'+
                    '<a href="caoxuexuanze.html"><li>'+
                        '<img src="../img/benxin/write.png">'+
                        '<p>自抄</p>'+
                    '</li></a>'+
                '</ul>';
                $('#main').append(html);
                }
            });
    $('.page').on('click','#zhuchao',function(){
        function getCookie(name) {
                var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
                if (arr != null) return unescape(arr[2]);
                return null;
            }
        var versionId = getUrlParam('vid');
        var csrftoken = getCookie('csrftoken');
        $.ajax({
                    url: '/fe/assistance/user_transcription/'+userTranscriptionID,
                    async: false,
                    type: "post",
                    beforeSend: function(xhr, settings) {
                            xhr.setRequestHeader("X-CSRFToken", csrftoken);
                        },
                    success: function (data) {
                        if(data.status=='410'){
                            alert('已抄完');
                        }
                        else if(data.status=='403'){
                            alert('不能助抄自己的经书');
                        }else{
                            var page_num = data.data.page_num;
                        $('#zhuchao').attr("href",'zhuchaoxie.html?id='+userTranscriptionID + '&pagenum=' + page_num+'&vid=' + versionId);
                        }
                    }
                });
    })
</script>
</html>